package jzh.cloud.user.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import jzh.cloud.common.entity.Goods;
import jzh.cloud.common.entity.User;
import jzh.cloud.user.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
@AllArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping("/getUser/{id}")
    @SentinelResource(value = "getUser")
    public User getUser(@PathVariable Long id) {
        return userService.getUser(id);
    }

    @GetMapping("/redisGeo")
    public String redisGeo() {
        return userService.redisGeo();
    }

    @PostMapping("/createUser")
    public String createUser(@RequestBody User user) {
        return userService.createUser(user);
    }

    @PostMapping("/createGoods")
    public String createGoods(@RequestBody Goods goods) {
        return userService.createGoods(goods);
    }
}
